<?php


namespace app\admin\controller\manage;


use app\admin\model\AllocRule;
use app\common\Common;
use think\facade\Validate;
use think\Request;

class Rule extends Common
{

    public function detRule(Request $request)
    {
//        $jwt = $request->_user;
        $det = AllocRule::allocDet("af");
        return successJson("success",$det);
    }

    public function saveRule(Request $request)
    {
        $data = $request->param();
        $validate = Validate::make([
            "rule_type|规则类型" => "require",
        ]);
        if (!$validate->check($data)) {
            return failedJson($validate->getError());
        }
        $dataS["rule_type"] = $data["rule_type"];
        $dataS["staff_no"] = $request->param("staff_no","");
        $res = AllocRule::allocSave($dataS,"af");
        if($res){
            return failedJson($res);
        }
        return successJson("success","成功");
    }
}